// Bitmap Font
// (c) jimon game studio

#ifndef JEH_CBITMAPFONT
#define JEH_CBITMAPFONT

#include "IFont.h"
#include "IBuffer.h"
#include "jeStl.h"
#include "IJEDManager.h"

namespace je
{
	namespace video
	{
		//! Bitmap Font
		class CBitmapFont:public je::video::IFont
		{
		protected:
			s32 CurrentVertSize;

			jeStringd FontImageName;
			media::jeImageResource * ImageResource;

			f32 FontSize;

			typedef jeDynamicArray<CharMetrics*> FontCharsArrayType;
			FontCharsArrayType FontChars;

			typedef jeMap<je_wchar_t,jeVector2df> FontKerningInternalMapType;
			typedef jeMap<je_wchar_t,FontKerningInternalMapType*> FontKerningMapType;
			FontKerningMapType FontKerningMap;

		public:
			//! Constructor
			CBitmapFont(core::IBuffer * Buffer);

			//! Destructor
			~CBitmapFont();

			//! Render Text
			void RenderText(IImage * Image,const jeStringd & Text,const jeVector2di & DrawPosition,u1 EnableKerning = false,u1 EnableCharsAlphaBlending = false);

			//! Calculate Text Size
			jeVector2di CalculateTextSize(const jeStringd & Text,u1 EnableKerning = false);

			//! Get Font Image
			video::IImage * GetFontImage();

			//! Get Font Resource
			//! If return null, use GetFontImage instead
			media::jeImageResource * GetFontResource();

			//! Get Char Metrics
			CharMetrics * GetCharMetrics(je_wchar_t Code);

			//! Get Kerning
			jeVector2df GetKerning(je_wchar_t PreviousChar,je_wchar_t CurrentChar);
		};
	}
}

#endif
